var e = require("../../../@babel/runtime/helpers/interopRequireDefault"), r = e(require("../../../@babel/runtime/regenerator")), t = require("../../../@babel/runtime/helpers/createForOfIteratorHelper"), a = require("../../../@babel/runtime/helpers/asyncToGenerator"), i = new (e(require("../../../http/order")).default)();

Component({
    properties: {
        postInformation: {
            type: Array,
            observer: function(e) {
                0 != e.length && (console.log(e), this.setData({
                    radio: e[0].id
                }));
            }
        },
        freeData: {
            type: Object
        }
    },
    data: {
        radio: "",
        icon: {
            normal: "./images/normal.png",
            active: "./images/active.png"
        }
    },
    methods: {
        onChange: function(e) {
            this.setData({
                radio: e.detail
            });
            var r = this.properties.postInformation.find(function(r) {
                return r.id == e.detail;
            });
            this.triggerEvent("changePost", r);
        },
        getPostInformation: function() {
            var e = this;
            return a(r.default.mark(function a() {
                var s, n, o, d, p, u;
                return r.default.wrap(function(r) {
                    for (;;) switch (r.prev = r.next) {
                      case 0:
                        return s = {
                            addressId: e.data.addressDetails.addressId,
                            omsOrderList: e.data.orderIds.split(",")
                        }, r.next = 3, i.postInformation(s);

                      case 3:
                        n = r.sent, o = [], d = t(n.data.omsOrderShippingPriceVOList);
                        try {
                            for (d.s(); !(p = d.n()).done; ) u = p.value, o.push({
                                id: u.shippingTemplatePriceId,
                                money: u.farShippingMoney,
                                name: u.expressCompanyName,
                                type: 0
                            });
                        } catch (e) {
                            d.e(e);
                        } finally {
                            d.f();
                        }
                        n.data.amsCouponHistoryVO && o.push({
                            id: n.data.amsCouponHistoryVO.couponHistoryId,
                            money: "",
                            name: "免邮券",
                            type: 1
                        }), e.setData({
                            postInformation: o,
                            addPickParams: {
                                addressId: e.data.addressDetails.addressId,
                                omsOrderList: e.data.orderIds.split(","),
                                shippingCouponHistoryId: o[0].id,
                                type: o[0].type
                            },
                            freeData: {
                                freeNum: n.data.freeNum,
                                freePrice: n.data.freePrice
                            }
                        });

                      case 9:
                      case "end":
                        return r.stop();
                    }
                }, a);
            }))();
        }
    }
});